<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
   
<title>个人资料</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/common.js"></script>

</head>
<script type="text/javascript">
// 屏蔽屏幕自身手势
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
var storage = window.localStorage;
var userCode = storage.getItem("primaryRole");
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return  decodeURI(r[2]); return null;
}

function setsex(){
	$("#sex").hide();
	$("#sexselect").show();
}

function setName(){
	$("#realName").hide();
	$("#realNametext").show();
}

function save(){
	var name = $("#realNametext").val();
	var sex = $("#sexselect").find("option:selected").val();
	var birth = $("#birth").val();
	if(name=='' || name==null){
		alert("姓名不能为空");
		return;
	}
	if(sex=='' || sex==null){
		alert("性别不能为空");
		return;
	}
	if(birth=='' || birth==null){
		alert("生日不能为空");
		return;
	}
	$.ajax({
       url: "./user/createRole",
       type: "POST",
       data:{
			userCode : userCode,
			name : name,
			sex : sex,
			birth : birth
		},
       dataType: 'json',
       cache: false,
       success: function (ret) {
    	   	if (ret.resultCode==0) {
    	   		alert("角色创建成功");
    	   		window.location.href = "./jsp/personalCenter/myrole.jsp";
          	}else{
          		alert("角色创建失败");
          		window.location.reload(); 
          	}
       	}
   	});
}
</script>
  
<body ontouchstart>
<div class="container js_container">
  </div>
  
  <div class="weui_cells weui_cells_access">
      <a class="weui_cell" href="javascript:;">
          <div class="weui_cell_hd">
       	  </div>
          <div class="weui_cell_bd weui_cell_primary">
              <p style="text-align: center;">请输入角色信息</p>
          </div>
      </a>
  </div>
    <div class="weui_cells">
          <div class="weui_cell">
             <div class="weui_cell_bd weui_cell_primary" onclick="setName()">
                 <p>姓&nbsp;名
                 	<span id="realName"></span>
                 	<input class="weui_input" type="text" style="display: none;width:70%;" id="realNametext">
                 </p>
             </div>
             <div class="weui_cell_ft"></div>
        </div>
        <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" onclick="setsex()"> 
                    <p>性&nbsp;别
                    	<span id="sex"></span>
                    	<select style="display: none;width:70%;" id="sexselect">
                    		<option value="0">男</option>
                    		<option value="1">女</option>
                    	</select>
                   	</p>
                </div>
                <div class="weui_cell_ft"></div>
            </div>
  			<div class="weui_cell">
                <div class="weui_cell_hd"><label for="" class="weui_label" style="width: 5em">出生日期</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="date" value="" id="birth">
                </div>
            </div>

        </div>
		<footer style="position: fixed;bottom: 1px;width: 100%;">
  			<a class="weui_btn" style="color:#fff;background-color: #337ab7;" onclick="save()">保存</a>
		</footer> 
</body>
</html>
